import Vue from 'vue'
import axios from './router/axios'
import VueAxios from 'vue-axios'
import App from './App'
import router from './router/router'
import './cache'
import store from './store'
import './styles/common.scss'
import utils from './utils/utils'
import md5 from 'js-md5'
import VueClipBoard from 'vue-clipboard2'

import {
  trim,
  groupBy,
  showLoading,
  hideLoading,
  dateFormat,
  deepClone,
  isNumberByGe0,
  uploadFile,
  isIdCardNo,
  isPhoneNo,
  isEmailNo,
  isAllNumber,
  fileNameFromUrl,
  ciphertext,
  logout,
  getLoginedExpiresTime,
  aesEncrypt,
  pushByNewPage,
  upToInt,
  compressImg,
  startsWith
} from '@/utils/utils'

import Cookies from 'js-cookie'

Vue.use(router)
Vue.use(VueAxios, axios)
Vue.use(VueClipBoard)

import Toast from 'vue-toastification'
import 'vue-toastification/dist/index.css'

const options = {
  position: 'bottom-center',
  timeout: 2000,
  closeOnClick: true,
  pauseOnFocusLoss: true,
  pauseOnHover: true,
  draggable: true,
  draggablePercent: 0.6,
  showCloseButtonOnHover: false,
  hideProgressBar: false,
  closeButton: 'button',
  icon: true,
  rtl: false
}

Vue.use(Toast, options)

Vue.prototype.$filePrefixUrl = 'https://www.xinyuxuapp.com/rel/sys/common/static/'

Vue.prototype.publicPath = process.env.BASE_URL
Vue.prototype.$trim = trim
Vue.prototype.$groupBy = groupBy

Vue.prototype.$utils = utils
Vue.prototype.$showLoading = showLoading
Vue.prototype.$hideLoading = hideLoading
Vue.prototype.$deepClone = deepClone
Vue.prototype.$uploadFile = uploadFile
Vue.config.productionTip = false

Vue.prototype.$isNumberByGe0 = isNumberByGe0
Vue.prototype.$cookies = Cookies
Vue.prototype.$dateFormat = dateFormat

Vue.prototype.$isIdCardNo = isIdCardNo
Vue.prototype.$isPhoneNo = isPhoneNo
Vue.prototype.$isEmailNo = isEmailNo
Vue.prototype.$isAllNumber = isAllNumber
Vue.prototype.$fileNameFromUrl = fileNameFromUrl
Vue.prototype.$ciphertext = ciphertext
Vue.prototype.$md5 = md5
Vue.prototype.$getLoginedExpiresTime = getLoginedExpiresTime
Vue.prototype.$aesEncrypt = aesEncrypt

Vue.prototype.$logout = logout

Vue.prototype.$pushByNewPage = pushByNewPage

Vue.prototype.$upToInt = upToInt
Vue.prototype.$compressImg = compressImg

Vue.prototype.$startsWith = startsWith

Vue.directive('removeAriaHidden', {
  bind(el, binding) {
    let ariaEls = el.querySelectorAll('.el-radio__original')
    ariaEls.forEach((item) => {
      item.removeAttribute('aria-hidden')
    })
  }
})

new Vue({
  router,
  store,
  render: (h) => h(App)
}).$mount('#app')
